import { defHttp } from "/@/utils/http/axios"
import { Modal } from "ant-design-vue"

enum Api {
  page = "/auth-service/onlineUser/page",
  get = "/auth-service/onlineUser/get",
  forceLogout = "/auth-service/onlineUser/forceLogout",
  forceLogoutBatch = "/auth-service/onlineUser/forceLogoutBatch",
}

export const page = (params) => defHttp.get({ url: Api.page, params })
export const getOnlineUser = (params) => defHttp.get({ url: Api.get, params })

export const forceLogout = (params, handleSuccess) => {
  return defHttp.delete({ url: Api.forceLogout, params }, { joinParamsToUrl: true }).then(() => {
    handleSuccess()
  })
}

export const forceLogoutBatch = (params, handleSuccess) => {
  Modal.confirm({
    title: "确认强退",
    content: "是否强退选中用户",
    okText: "确认",
    cancelText: "取消",
    onOk: () => {
      return defHttp.delete({ url: Api.forceLogoutBatch, data: params }, { joinParamsToUrl: true }).then(() => {
        handleSuccess()
      })
    },
  })
}
